﻿using B.S.Material.Domain.Production_rejection;
using B.S.Material.ErrorCode;
using B.S.Material.Read.Api.Applications.Command.StrippingCommand;
using MediatR;
using SqlSugar;

namespace B.S.Material.Read.Api.Applications.Handler.StrippingHandler
{
    public class FTStrippingHandelr : IRequestHandler<FTStrippingCommand, ApiResult<List<Stripping>>>
    {
        private readonly ISqlSugarClient db;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="db"></param>
        /// <param name="config"></param>
        public FTStrippingHandelr(ISqlSugarClient db)
        {
            this.db = db;

        }

        public async Task<ApiResult<List<Stripping>>> Handle(FTStrippingCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<Stripping>> result = new ApiResult<List<Stripping>>();
            var list = await db.Queryable<Stripping>().Where(x => x.IsDel == false && x.StrippingId == request.StrippingId).ToListAsync();
            result.data = list;
            result.Code = ApiEnum.显示成功;
            result.MAG = ApiEnum.显示成功.ToString();
            return await Task.FromResult(result);
        }
    }
}
